package jd.se.admin.UserControl;

import jd.se.common.Utils;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

public class UserService {

    public void deleteUser(UserDto dto) {
        SqlSession sess = Utils.openSession();
        try{
            UserDao dao = sess.getMapper(UserDao.class);
            dao.deleteUser(dto.getU_id());
            sess.commit();
        }catch(Exception e){
            sess.rollback();
            throw new RuntimeException("删除用户信息失败！",e);
        }finally {
            sess.close();
        }
    }

    public List<User> getUserList() {
        SqlSession sess = Utils.openSession();
        try{
            UserDao dao = sess.getMapper(UserDao.class);
            List<User> UserList = dao.findUserList();
            sess.commit();
            return UserList;
        }catch(Exception e){
            sess.rollback();
            throw new RuntimeException("无法获取待审核书籍！",e);
        }finally {
            sess.close();
        }
    }
}
